package operator;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperator implements IOperator{
    public void work(BookList bookList){
        System.out.println("请输入你想查找的图书名字：");
        Scanner scanner = new Scanner(System.in);
        String bookname = scanner.nextLine();
        int size = bookList.getUseSize();
        for(int i = 0; i < size; i++){
            Book book = bookList.getPos(i);
            if(bookname.equals(book.getName())){
                System.out.println("找到了！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书！");
    }
}
